var vm = new Vue({
    el: '#app',
    data: function () {
        return {
            host: '#(host)',
            user: #(userJson),
            username: '',
            password: '',
            isLogin: true
        }
    },
    methods: {
        submitSearch() {
            location.href = "/?searchKeyword=" + document.getElementById("searchKeyword").value
        },
        loginClick() {
            axios.post("/user/loginSubmit", {
                "username": this.username,
                "password": this.password
            }).then(function (response) {
                if (response.data.code != 200) {
                    vm.$message.error(response.data.mess, 2000);
                } else {
                    location.href = "/"
                }
            });
        },
        registerClick() {
            axios.post("/user/registerSubmit", {
                "username": this.username,
                "password": this.password
            }).then(function (response) {
                if (response.data.code != 200) {
                    vm.$message.error(response.data.mess, 2000);
                } else {
                    location.href = "/"
                }
            });
        },
        registerOrLoginClick() {
            axios.post("/user/registerOrLoginSubmit", {
                "username": this.username,
                "password": this.password
            }).then(function (response) {
                if (response.data.code != 200) {
                    vm.$message.error(response.data.mess, 2000);
                } else {
                    location.href = "/"
                }
            });
        }
    },
    mounted: function () {
    }
})